home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bthread.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  2.5 KB  |  96 lines

  1. /*
  2.  *
  3.  * $Id: k3bthread.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef _K3B_THREAD_H_
  18. #define _K3B_THREAD_H_
  19.  
  20. #include <qthread.h>
  21. #include "k3b_export.h"
  22.  
  23. class QObject;
  24.  
  25. /**
  26.  * The threaded couterpart to K3bJob
  27.  * instead of emitting the information signals
  28.  * one has to use the emitXXX methods which will post
  29.  * K3bProgressInfoEvents to the eventhandler.
  30.  *
  31.  * K3bThreadJob can be used to automatically wrap the thread in a K3bJob.
  32.  *
  33.  * As in K3bJob it is important to call emitStarted and emitFinished.
  34.  *
  35.  * See K3bThreadJob for more information.
  36.  */
  37. class LIBK3B_EXPORT K3bThread : public QThread
  38. {
  39.  public:
  40.   K3bThread( QObject* eventHandler = 0 );
  41.   K3bThread( unsigned int stackSize, QObject* eventHandler = 0  );
  42.   virtual ~K3bThread();
  43.  
  44.   void setProgressInfoEventHandler( QObject* eventHandler );
  45.  
  46.   /**
  47.    * Initialize the thread before starting it in the GUi thread.
  48.    * K3bThreadJob automatically calls this.
  49.    *
  50.    * The default implementation does nothing.
  51.    */
  52.   virtual void init();
  53.  
  54.   /**
  55.    * to provide the same api like K3bJob
  56.    * the default implementation calls terminate and
  57.    * emitCancled() and emitFinished(false)
  58.    */
  59.   virtual void cancel();
  60.  
  61.   virtual QString jobDescription() const;
  62.   virtual QString jobDetails() const;
  63.  
  64.   /**
  65.    * waits until all running K3bThread have finished.
  66.    * This is used by K3bApplication.
  67.    */
  68.   static void waitUntilFinished();
  69.  
  70.  protected:
  71.   virtual void run() = 0;
  72.  
  73.   /**
  74.    * uses the K3bJob::MessageType enum
  75.    */
  76.   void emitInfoMessage( const QString& msg, int type );
  77.   void emitPercent( int p );
  78.   void emitSubPercent( int p );
  79.   void emitStarted();
  80.   void emitCanceled();
  81.   void emitFinished( bool success );
  82.   void emitProcessedSize( int processed, int size );
  83.   void emitProcessedSubSize( int processed, int size );
  84.   void emitNewTask( const QString& job );
  85.   void emitNewSubTask( const QString& job );
  86.   void emitDebuggingOutput(const QString&, const QString&);
  87.   void emitData( const char* data, int len );
  88.   void emitNextTrack( int track, int trackNum );
  89.  
  90.  private:
  91.   class Private;
  92.   Private* d;
  93. };
  94.  
  95. #endif
  96.